package com.webserver.core;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class ClientHandLer implements  Runnable{
    private Socket socket;
    public  ClientHandLer(Socket socket){
        this.socket=socket;
    }
    @Override
    public void run() {
        try {
            InputStream in= socket.getInputStream();
            StringBuilder sbd=new StringBuilder();
            int d;
            char pre='a',cur='a';//pre上一次读取的字符  cur本次读取到的字符
            while ((d=in.read())!=-1){
                pre=(char) d;
                if (pre==13&cur==10){
                    break;
                }
                sbd.append(pre);
                cur=pre;
            }
            String curpre=sbd.toString();
            System.out.println(curpre);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
